package Z05Lambda.HelloLambda;



import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.logging.Filter;

public class TestLambda {
    public static void main(String[] args) {
        Random r = new Random();
        List<Hero> heroes = new ArrayList<>();
        for (int i = 0;i < 10 ;i++) {
            heroes.add(new Hero("hero:" + i, r.nextInt(1000), r.nextInt(100)));
        }
        System.out.println("初始化后的集合：");
        System.out.println(heroes);
        System.out.println("筛选出 hp > 100 && damange < 50 的英雄");
        filter(heroes);

        HeroChecker checker = new HeroChecker() {
            @Override
            public boolean test(Hero h) {
                return (h.hp > 100 && h.damage < 50);
            }
        };
        System.out.println("======================");
    }



    private static void filter(List<Hero> heroes) {
        for (Hero hero: heroes){
            if (hero.hp > 100 && hero.damage < 50){
                System.out.print(hero);
            }
        }
    }


}

